
"""
Created on Tue Feb 19 14:55:43 2013

@author: aponteeduarddo@gmail.com
Copyright Eduardo Aponte 2013.
"""

from mex_binder import binder_py

eyelink_get_next_data = binder_py('mx_eyelink_get_next_data')
eyelink_get_next_data.mx_c.headers = ['<eyelink.h>','"mex.h"']
eyelink_get_next_data.bindo += []
eyelink_get_next_data.mx_c.code = \
"""
INT16 _main( void )
{
    return eyelink_get_next_data( NULL ); ;
}

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    mwSize td[2] = {1,1};
    double *status;
    
    /* Verify input arguments. */
    if(nrhs != 0 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs > 1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
      
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status = mxGetPr(plhs[0]);    
    *status = (double ) _main( ); 
    return;
}
"""

eyelink_get_next_data.mx_c.mdoc = \
"""function [ ] = mx_eyelink_get_next_data( )
%MX_EYELINK_GET_NEXT_DATA Fetches next data item from link buffer. Usually 
% called with <buf> = NULL, and returns the data item type. If the item is not
% wanted, simply ignore it. Otherwise, call eyelink_get_float_data() to read it
% into a buffer.
%
% Returns:
% 0 if no data, SAMPLE_TYPE if sample, else event type.
%
"""
eyelink_get_next_data.write_c()
eyelink_get_next_data.write_m()
eyelink_get_next_data.compile()
eyelink_get_next_data.write_sh()

